//
// Created by 高森森 on 2022/2/10.
//

#ifndef LEETCODE_SOLUTION30_H
#define LEETCODE_SOLUTION30_H
#include<iostream>
#include<vector>
using namespace std;
class Solution30 {
public:
    vector<vector<char>> rotateTheBox(vector<vector<char>>& box) {
        int row=box.size();
        int col=box[0].size();
        vector<vector<char>>ans;
        for(int i=0;i<col;i++)
        {
            vector<char>tmp;
            for(int j=row-1;j>=0;j--){
                tmp.push_back(box[j][i]);
            }
            ans.push_back(tmp);
        }
        int size=row;
        int newRow=col;
        for(int j=0;j<size;j++){
           int i=newRow-1;
           int emptyCnt=0;
           while(i>=0){
               if(ans[i][j]=='.')
               {
                   emptyCnt++;
               }
               else if(ans[i][j]=='*'){
                   emptyCnt=0;
               }
               else {
                   if(emptyCnt>0){
                       ans[i+emptyCnt][j]='#';
                       ans[i][j]='.';
                   }

               }
               i--;
           }
        }
        return ans;
    }
};


#endif //LEETCODE_SOLUTION30_H
